package com.mogist.hqc.module.community.adapter

import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.mogist.hqc.R
import com.mogist.hqc.entitys.response.UriData

/**
 * 作用：订单列表
 * 作者：赵小白 email:vvtale@gmail.com  
 * 修改人：
 * 修改时间：
 * 修改备注：
 */
class CommunityAddAdapter : BaseQuickAdapter<UriData, BaseViewHolder>(
        R.layout.item_community_add)
{
    override fun convert(helper: BaseViewHolder, item: UriData)
    { //iImage iClose
        helper.addOnClickListener(R.id.iClose)
        if (item.uri == null)
        {
            helper.setImageResource(R.id.iImage,R.drawable.i_add_img)
                    .setVisible(R.id.iClose,false)
        }
        else
        {
            helper.setVisible(R.id.iClose,true)
            val options =
                    RequestOptions().centerCrop()
                            .dontAnimate()

            val image = helper.getView<ImageView>(R.id.iImage)
            Glide.with(image.getContext())
                    .load(item.uri)
                    .apply(options)
                    .into(image)

        }
    }

}